package com.lma.crm.web.interceptor;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

public class LoginInterceptor extends MethodFilterInterceptor {

	private static final long serialVersionUID = 1L;

	@Override
	public String doIntercept(ActionInvocation invocation) throws Exception {
		Object object = ActionContext.getContext().getSession().get("loginStaff");
		if(object == null) {
			//获取当前运行action
			Object action = invocation.getAction();
			if(action instanceof ActionSupport) {
				ActionSupport actionSupport = (ActionSupport)action;
				actionSupport.addFieldError("", "请登录");
			}
			return "login";
		}
		return invocation.invoke();
	}
	
}
